package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.entity.Address;
import com.cskaoyan.bean.vo.BasePageData;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.controller.wx.service.AddressService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Auther Wenjian_Yang
 * @Date 2021/10/22
 */
@RestController
@RequestMapping("wx/address")
public class WxAddressController {
    @Resource
    AddressService addressService;

    //地址列表信息
    @GetMapping("list")
    public BaseRespVo list(){
        BasePageData<Address> query = addressService.query();
        return BaseRespVo.ok(query);
    }

    //地址详情信息
    @GetMapping("detail")
    public BaseRespVo detail(Integer id){
        Address detail = addressService.detail(id);
        return BaseRespVo.ok(detail);
    }

    //地址信息新建/保存
    @PostMapping("save")
    public BaseRespVo save(@RequestBody Address address){
        int row = addressService.save(address);
        return BaseRespVo.ok(row);
    }

    //删除地址信息
    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody Address address){
        addressService.delete(address);
        return BaseRespVo.ok();
    }

}
